package com.xpffly.design.mediator.service.impl;

import com.xpffly.design.mediator.service.AbstractColleague;
import com.xpffly.design.mediator.service.AbstractMediator;

/**
 * @Author: xpengfei
 * @Date: 2021/4/5 20:07
 * @Description：库存管理
 */
public class Stock extends AbstractColleague {
    public Stock(AbstractMediator mediator) {
        super(mediator);
    }

    /**
     * 初始库存 100 台
     */
    private static int COMPUTER_NUMBER = 100;

    /**
     * 库存增加
     *
     * @param number
     */
    public void increase(int number) {
        COMPUTER_NUMBER += number;
        System.out.println("库存数量为：" + COMPUTER_NUMBER);
    }

    /**
     * 库存降低
     *
     * @param number
     */
    public void decrease(int number) {
        COMPUTER_NUMBER -= number;
        System.out.println("销售后库存数量为：" + COMPUTER_NUMBER);
    }

    /**
     * 获取库存数量
     *
     * @return
     */
    public int getStockNumber() {
        return COMPUTER_NUMBER;
    }

    /**
     * 库存压力增大，要通知采购人员不要再采购了，同时通知销售人员尽快销售
     */
    public void clearStock() {
        System.out.println("待清理库存数量为：" + COMPUTER_NUMBER);
        super.mediator.execute("stock.clear");
    }
}
